﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GMS.BIZ;
using System.Collections;

namespace Web.Information
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
                if (!((Account)Session["Account"]).RoleCurrent.Equals('s')) Response.Redirect("Default.aspx");
                Student myStudent = (Student)Session["Student"];
                //绑定DropDownList
                if (!IsPostBack)
                {
                    DropDownList_gender.Items.Add("男");
                    DropDownList_gender.Items.Add("女");
                }
                Label_stdid.Text = myStudent.StudentID;
                Label_classid.Text = myStudent.ClassID;
                Label_graduateyear.Text = myStudent.GraduateYear;
                TextBox_stdname.Text = myStudent.StudentName;
                TextBox_stdmail.Text = myStudent.StudentMail;
                if (myStudent.StudentGender.Trim() == "男")
                    DropDownList_gender.SelectedIndex = 0;
                else
                    DropDownList_gender.SelectedIndex = 1;
                TextBox_stdpolicy.Text = myStudent.StudentPolicy;
                TextBox_stdhobby.Text = myStudent.StudentHobby;
                Label_result.Text = "";
        }
        protected void ImageButton_Edit_Click(object sender, ImageClickEventArgs e)
        {
            Student mystudent = (Student)Session["Student"];
            mystudent.StudentName = TextBox_stdname.Text.ToString();
            mystudent.StudentMail = TextBox_stdmail.Text.ToString();
            mystudent.StudentGender = DropDownList_gender.SelectedItem.Text.ToString();
            mystudent.StudentPolicy = TextBox_stdpolicy.Text.ToString();
            mystudent.StudentHobby = TextBox_stdhobby.Text.ToString();
            string str=mystudent.PersonalInfomationEdit();
            if (str.CompareTo(Resources.ErrorMessage.OK) == 0)
                Response.Redirect("StuInformation.aspx");
            else
                Label_result.Text = Resources.ErrorMessage.DBOptError;
        }

        protected void ImageButton_Cancel_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("StuInformation.aspx");
        }
    }
}
